# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=pyopengl-accelerate
_pyname=PyOpenGL-accelerate
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.1.7
pkgrel=2
pkgdesc="Acceleration code for PyOpenGL (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url='https://pyopengl.sourceforge.io/'
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-pyopengl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('2b123621273a939f7fd2ec227541e399f9b5d4e815d69ae0bdb1b6c70a293680')

prepare() {
  cd "${srcdir}"
  rm -fr python-build-${MSYSTEM} | true
  cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  "${MINGW_PREFIX}"/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/python setup.py check
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    "${MINGW_PREFIX}"/bin/python setup.py install --prefix="${MINGW_PREFIX}" \
      --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
